package 数组.左右元素和的差值2574;

public class Solution {
    public int[] leftRightDifference(int[] nums) {
        int n = nums.length;
        int[] ans = new int[n];
        for(int i = 0; i < n; i++){
            int leftSum = 0, rightSum = 0;
            for(int j = 0; j < i; j++){
                leftSum += nums[j];
            }

            for(int j = i + 1; j < n; j++){
                rightSum += nums[j];
            }
            ans[i] = Math.abs(leftSum - rightSum);
        }
        return ans;
    }
}
